package com.gl.mapper;

import com.gl.pojo.entity.Application;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ApplicationMapper {
    List<Application> selectReviewed(String username);

    // 检查待处理申请
    @Select("SELECT COUNT(*) FROM meetsynth.application WHERE user_id = #{userId} AND status = 'pending'")
    boolean existsPendingUserById(String userId);

    // 插入新申请
    @Insert("INSERT INTO application (user_id, apply_reason, status, username) " +
            "VALUES (#{userId}, #{reason}, #{status}, #{username})")
    int insertApplication(Application application);

    List<Application> selectPending(String username);

    int updateApplicationStatus(Integer id, String status, String reviewer);

    Application selectById(Integer id);
}
